package com.lcm.oj.huya.study.fail;

import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author Coder-lcm
 * @date 2021/5/17
 */
public class FailSafe {
    public static void main(String[] args) {
        Map<Integer, String> map = new ConcurrentHashMap<>();
        for (int i = 0; i < 3; i++) {
            map.put(i,i+"");
        }

        Iterator<Integer> keys = map.keySet().iterator();
        while (keys.hasNext()) {
            System.out.println(keys.next());
            // 尝试在迭代过程对map进行修改
            map.put(4, "4"); //不会抛异常
        }


    }
}
